<?php
/**
*
* @package ucp
* @version $Id: ucp_mail_user.php 1 2008-29-12 20:26:33Z Alexander $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

/**
* ucp_mail_user
* Mailing a member.
* @package ucp
*/
class ucp_mail_user
{
	var $u_action;
	
	function main($id, $mode)
	{
		global $phpbb_root_path, $phpEx, $template, $db, $user;
		
		$user_to_mail = request_var('u', null);
		// Get the user setting of he or she has enabled mailMe
		$user_can_mail = $this->get_user_mail_on($user_to_mail);
		
		if(!$user_can_mail)
		{
			trigger_error(sprintf($user->lang['CANT_MAIL_USER'], $this->get_user_name($user_to_mail)), E_USER_WARNING);
			return;
		}
		
		$submit = (isset($_POST['submit'])) ? true : false;
		
		if($submit)
		{
			// mail the user.
		}
		else
		{
			// bulled up the form
			
		}
	}
	
	function get_user_mail_on($user_to_mail)
	{
		global $db;
		
		$sql = "SELECT * FROM " . USERS_TABLE . " WHERE user_id = $user_to_mail";
		$query = $db->sql_query($sql);
		$row = $db->sql_fetchrow($query);
		$db->sql_freeresult();
		
		return ($row['user_mail_me'] == 1) ? true : false;
	}
	
	function get_user_name($user)
	{
		global $db;
		
		$sql = "SELECT * FROM " . USERS_TABLE . " WHERE user_id = $user_to_mail";
		$query = $db->sql_query($sql);
		$row = $db->sql_fetchrow($query);
		$db->sql_freeresult();
		
		return $row['user_name'];
	}
}
?>